package com.tjsinfo.tjsoa.system.action;


import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.jbpm.taskmgmt.exe.TaskInstance;
import org.json.JSONArray;
import org.json.JSONObject;

import com.tjsinfo.tjsoa.addresslist.bo.IAddressListAndFilePendingBo;
import com.tjsinfo.tjsoa.common.SessionUser;
import com.tjsinfo.tjsoa.documentationflow.dangweifawen.bo.ITDangweifawenNeirongBO;
import com.tjsinfo.tjsoa.documentationflow.dangweifawen.vo.TDangweifawenNeirong;
import com.tjsinfo.tjsoa.documentationflow.dangweishouwen.bo.ITDangweishouwenNeirongBO;
import com.tjsinfo.tjsoa.documentationflow.dangweishouwen.vo.TDangweishouwenNeirong;
//import com.tjsinfo.tjsoa.documentationflow.gonghuifawei.bo.ITGonghuifaweiNeirongBO;
//import com.tjsinfo.tjsoa.documentationflow.gonghuifawei.vo.TGonghuifaweiNeirong;
//import com.tjsinfo.tjsoa.documentationflow.tongzhifawen.bo.ITTongZhifawenNeirongBO;
//import com.tjsinfo.tjsoa.documentationflow.tongzhifawen.vo.TTongzhifawenNeirong;
import com.tjsinfo.tjsoa.documentationflow.xingzhengfawen.bo.ITXingzhengfawenNeirongBO;
import com.tjsinfo.tjsoa.documentationflow.xingzhengfawen.vo.TXingzhengfawenNeirong;
import com.tjsinfo.tjsoa.documentationflow.xingzhengshouwen.bo.ITXingzhengshouwenNeirongBO;
import com.tjsinfo.tjsoa.documentationflow.xingzhengshouwen.vo.TXingzhengshouwenNeirong;
import com.tjsinfo.tjsoa.mail.bo.ITjsemailReceivedBo;
import com.tjsinfo.tjsoa.meetingroom.bo.IMeetingRoomInceptBo;
import com.tjsinfo.tjsoa.messageImportant.bo.IMessageImportantInceptBo;
import com.tjsinfo.tjsoa.system.vo.TSystemUser;
import com.tjsinfo.tjsoa.system.vo.User;
import com.tjsinfo.tjsoa.workflow.WorkFlowTemplate;

public class MainAction extends Action {
	private ITDangweishouwenNeirongBO dangweishouwenNeirongBO;
	private ITDangweifawenNeirongBO dangweifawenNeirongBO;
	private ITXingzhengshouwenNeirongBO xingzhengshouwenNeirongBO;
	private ITXingzhengfawenNeirongBO xingzhengfawenNeirongBO;
	private WorkFlowTemplate workFlowTemplate;

	public ITXingzhengfawenNeirongBO getXingzhengfawenNeirongBO() {
		return xingzhengfawenNeirongBO;
	}

	public void setXingzhengfawenNeirongBO(
			ITXingzhengfawenNeirongBO xingzhengfawenNeirongBO) {
		this.xingzhengfawenNeirongBO = xingzhengfawenNeirongBO;
	}
	
	public ITDangweifawenNeirongBO getDangweifawenNeirongBO() {
		return dangweifawenNeirongBO;
	}

	public void setDangweifawenNeirongBO(
			ITDangweifawenNeirongBO dangweifawenNeirongBO) {
		this.dangweifawenNeirongBO = dangweifawenNeirongBO;
	}

	public WorkFlowTemplate getWorkFlowTemplate() {
		return workFlowTemplate;
	}

	public void setWorkFlowTemplate(WorkFlowTemplate workFlowTemplate) {
		this.workFlowTemplate = workFlowTemplate;
	}

	public ITDangweishouwenNeirongBO getDangweishouwenNeirongBO() {
		return dangweishouwenNeirongBO;
	}

	public void setDangweishouwenNeirongBO(
			ITDangweishouwenNeirongBO dangweishouwenNeirongBO) {
		this.dangweishouwenNeirongBO = dangweishouwenNeirongBO;
	}

	public ITXingzhengshouwenNeirongBO getXingzhengshouwenNeirongBO() {
		return xingzhengshouwenNeirongBO;
	}

	public void setXingzhengshouwenNeirongBO(
			ITXingzhengshouwenNeirongBO xingzhengshouwenNeirongBO) {
		this.xingzhengshouwenNeirongBO = xingzhengshouwenNeirongBO;
	}

	//王维 开始

	private ITjsemailReceivedBo tjsemailReceivedBo;
	private IMessageImportantInceptBo importantInceptBo;
	private IAddressListAndFilePendingBo addressListAndFilePendingBo;
	private IMeetingRoomInceptBo meetingRoomInceptBo;
	public void setMeetingRoomInceptBo(IMeetingRoomInceptBo meetingRoomInceptBo) {
		this.meetingRoomInceptBo = meetingRoomInceptBo;
	}
	public void setTjsemailReceivedBo(ITjsemailReceivedBo tjsemailReceivedBo) {
		this.tjsemailReceivedBo = tjsemailReceivedBo;
	}
	public void setImportantInceptBo(IMessageImportantInceptBo importantInceptBo) {
		this.importantInceptBo = importantInceptBo;
	}
	public void setAddressListAndFilePendingBo(
			IAddressListAndFilePendingBo addressListAndFilePendingBo) {
		this.addressListAndFilePendingBo = addressListAndFilePendingBo;
	}
	//王维 结束
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response) { 
		try {
//			User user = SessionUser.getUser(request);
//			Integer useridInt = user.getUser_id();
//			String useridStr = String.valueOf(useridInt);
//			//邮件
//			Integer weiduemailsize = tjsemailReceivedBo.selectWeiReadEmail(user.getUsername());
//			request.setAttribute("weiduemailsize", weiduemailsize);
//			//会议审批
////			Integer meetsize  = addressListAndFilePendingBo.findByUserIdAndTyle(user.getUser_id(), "会议审批").size();
////			request.setAttribute("meetsize", meetsize);
//			request.setAttribute("meetsize", 0);
//			//会议通知
//			TSystemUser systemUser = new TSystemUser();
//			systemUser.setUserName(user.getUsername());
//			Integer meettruesize  = meetingRoomInceptBo.getMainDai(systemUser);
//			request.setAttribute("meettruesize", meettruesize);
//			//会议拒绝
//			Integer meetfalsesize  = addressListAndFilePendingBo.findByUserIdAndTyle(useridInt, "会议申请拒绝").size();
//			request.setAttribute("meetfalsesize", meetfalsesize);
//			//多少个新文件
//			Integer newFile  = addressListAndFilePendingBo.findByUserIdAndTyle(useridInt, "文件速递").size();
//			request.setAttribute("newFile", newFile);
//			//重要提醒
//			String important = importantInceptBo.getDai(useridInt,user.getUsername());
//			request.setAttribute("important", important);
//	
//	//		Integer downxingzhengfawenCount = xingzhengfawenNeirongBO.selectDownXingZhengfaCount(1, useridInt, "行政发文");
//	//		request.setAttribute("downxingzhengfawenCount", downxingzhengfawenCount);
//			
//	//		Integer downdangweifawenCount = xingzhengfawenNeirongBO.selectDownDangWeifaCount(1, useridInt, "党委发文");
//	//	request.setAttribute("downdangweifawenCount", downdangweifawenCount);
//			
//			workFlowTemplate = new WorkFlowTemplate();
//			List<TDangweishouwenNeirong> dangweishouwenNeirongList =  selectTDangWeiShouwenDaiBan(useridInt);
//			if (dangweishouwenNeirongList.size() > 3) {
//				dangweishouwenNeirongList = dangweishouwenNeirongList.subList(0, 3);
//			}
//			request.setAttribute("dangweishouwenNeirongList", dangweishouwenNeirongList);
//			List<TDangweifawenNeirong> dangweifawenNeirongList = selectTDangWeiFawenDaiBan(useridInt);
//		
//			if (dangweifawenNeirongList.size() > 3) {
//				dangweifawenNeirongList = dangweifawenNeirongList.subList(0, 3);
//			}
//			request.setAttribute("dangweifawenNeirongList", dangweifawenNeirongList);
//			List<TXingzhengshouwenNeirong> xingzhengshouwenNeirongList = selectTXingzhengShouwenNeirongDaiBan(useridInt);
//			if (xingzhengshouwenNeirongList.size() > 3) {
//				xingzhengshouwenNeirongList = xingzhengshouwenNeirongList.subList(0, 3);
//			}
//			request.setAttribute("xingzhengshouwenNeirongList", xingzhengshouwenNeirongList);
//			List<TXingzhengfawenNeirong> xingzhengfawenNeirongList = selectTXingzhengfawenNeirongDaiBan(useridInt); 
//			
//			if (xingzhengfawenNeirongList.size() > 3) {
//				xingzhengfawenNeirongList = xingzhengfawenNeirongList.subList(0, 3);
//			}
//			request.setAttribute("xingzhengfawenNeirongList", xingzhengfawenNeirongList);
//			List<TDangweifawenNeirong> jiWeiFaWenList = selectTJiWeiFawenDaiBan(useridInt);			
//			if (jiWeiFaWenList.size() > 3) {
//				jiWeiFaWenList = jiWeiFaWenList.subList(0, 3);
//			}
//			request.setAttribute("jiWeiFaWenList", jiWeiFaWenList);
//			List<TDangweifawenNeirong> tuanWeiFaWenList = selectTTuanWeiFawenDaiBan(useridInt);			
//			if (tuanWeiFaWenList.size() > 3) {
//				tuanWeiFaWenList = tuanWeiFaWenList.subList(0, 3);
//			}
//			request.setAttribute("tuanWeiFaWenList", tuanWeiFaWenList);
//			List<TDangweifawenNeirong> gonghuifaweiNeirongList = selectTGongHuiFawenDaiBan(useridInt);			
//			if (gonghuifaweiNeirongList.size() > 3) {
//				gonghuifaweiNeirongList = gonghuifaweiNeirongList.subList(0, 3);
//			}
//			request.setAttribute("gonghuifaweiNeirongList", gonghuifaweiNeirongList);
//			List<String> xingzhengshanshuoList = new ArrayList<String>();			
//			int count = xingzhengfawenNeirongBO.selectTaskCont(useridInt, "核稿", "行政发文");
//			if(count != 0){
//				xingzhengshanshuoList.add("核稿("+count+")");
//			}			
//			count = xingzhengfawenNeirongBO.selectTaskCont(useridInt, "复核", "行政发文");
//			if(count != 0){
//				xingzhengshanshuoList.add("复核("+count+")");
//			}			
//			count = xingzhengfawenNeirongBO.selectTaskCont(useridInt, "会签", "行政发文");
//			if(count != 0){
//				xingzhengshanshuoList.add("会签("+count+")");
//			}
//			
//			count = xingzhengfawenNeirongBO.selectTaskCont(useridInt, "签发", "行政发文");
//			if(count != 0){
//				xingzhengshanshuoList.add("待签发("+count+")");
//			}
//			
//			count = xingzhengfawenNeirongBO.selectTaskCont(useridInt, "套红", "行政发文");			
//			if(count != 0){
//				xingzhengshanshuoList.add("套红("+count+")");
//			}
//			
//			count = xingzhengfawenNeirongBO.selectTaskCont(useridInt, "办公室主任复核", "行政发文") + xingzhengfawenNeirongBO.selectTaskCont(SessionUser.getUserId(request), "办公室主任二次复核", "行政发文");;
//			if(count != 0){
//				xingzhengshanshuoList.add("办公室主任审核("+count+")");
//			}
//			
//			count = xingzhengfawenNeirongBO.selectTaskCont(useridInt, "部门主管会签", "行政发文");
//			if(count != 0){
//				xingzhengshanshuoList.add("部门主管会签("+count+")");
//			}
//						
//			
//			request.setAttribute("xingzhengshanshuoList", xingzhengshanshuoList);
//			List<String> dangweishanshuoList = new ArrayList<String>();
//			
//			count = xingzhengfawenNeirongBO.selectTaskCont(useridInt, "核稿", "党委发文");
//			if(count != 0){
//				dangweishanshuoList.add("核稿("+count+")");
//			}
//			count = xingzhengfawenNeirongBO.selectTaskCont(useridInt, "复核", "党委发文");
//			if(count != 0){
//				dangweishanshuoList.add("复核("+count+")");
//			}
//			count = xingzhengfawenNeirongBO.selectTaskCont(useridInt, "会签", "党委发文");
//			if(count != 0){
//				dangweishanshuoList.add("会签("+count+")");
//			}
//			count = xingzhengfawenNeirongBO.selectTaskCont(useridInt, "签发", "党委发文");
//			if(count != 0){
//				dangweishanshuoList.add("待签发("+count+")");
//			}
//			count = xingzhengfawenNeirongBO.selectTaskCont(useridInt, "套红", "党委发文");
//			if(count != 0){
//				dangweishanshuoList.add("套红("+count+")");
//			}
//			count = xingzhengfawenNeirongBO.selectTaskCont(useridInt, "办公室主任复核", "党委发文") + xingzhengfawenNeirongBO.selectTaskCont(useridInt, "办公室主任二次复核", "党委发文");;
//			if(count != 0){
//				dangweishanshuoList.add("办公室主任审核("+count+")");
//			}
//			count = xingzhengfawenNeirongBO.selectTaskCont(useridInt, "部门主管会签", "党委发文");
//			if(count != 0){
//				dangweishanshuoList.add("部门主管会签("+count+")");
//			}
//			request.setAttribute("dangweishanshuoList", dangweishanshuoList);
			return mapping.findForward("success");
		} catch (Exception e) {
			e.printStackTrace();
			request.setAttribute("Exception", e);
			return mapping.findForward("failed");
		}
	}
	
	/**
	 * 获取党委收文待办
	 * @param request
	 * @return
	 */
	private List<TDangweishouwenNeirong> selectTDangWeiShouwenDaiBan(Integer useridInt){
		List<TDangweishouwenNeirong> dangweishouwenNeirongList = new ArrayList<TDangweishouwenNeirong>();
		dangweishouwenNeirongList = dangweishouwenNeirongBO.selectDangWeiShouWenDaiBan(useridInt);
		/*List list = workFlowTemplate.selectTask(SessionUser.getUserId(request).toString(), "党委收文");
		List sublist =  workFlowTemplate.selectTask(SessionUser.getUserId(request).toString(), "党委收文子流程");
		for (Iterator iterator = sublist.iterator(); iterator.hasNext();) {
			TaskInstance taskinstance = (TaskInstance) iterator.next();
			Long flowid = (Long) workFlowTemplate.getVariable("父流程ID", taskinstance.getProcessInstance().getId());
			taskinstance.setDescription(flowid.toString());
			taskinstance.setProcessInstance(null);
			list.add(taskinstance); 
		}
		Comparator comp = new Comparator(){
	          public int compare(Object o1,Object o2) {
	              TaskInstance p1=(TaskInstance)o1;
	              TaskInstance p2=(TaskInstance)o2; 
	             if(p1.getId()<p2.getId())
	                 return 1;
	             else
	                 return 0;
	             }
	        };
	        Collections.sort(list, comp);
		for (Iterator iterator = list.iterator(); iterator.hasNext();) {
			TaskInstance taskInstance = (TaskInstance) iterator.next();
			Long flowid = null;
			if(taskInstance.getProcessInstance() !=null)
			{
				flowid = taskInstance.getProcessInstance().getId();
			}
			else
			{
				flowid = Long.valueOf(taskInstance.getDescription());
			}
			TDangweishouwenNeirong dangweishouwenNeirong = new TDangweishouwenNeirong();
			dangweishouwenNeirong.setFlowid(Integer.parseInt(flowid.toString()));
			if( dangweishouwenNeirongBO.findByExample(dangweishouwenNeirong).size() >0)
			{
				dangweishouwenNeirong = (TDangweishouwenNeirong)dangweishouwenNeirongBO.findByExample(dangweishouwenNeirong).get(0);
				dangweishouwenNeirong.setTaskId(taskInstance.getId());
				dangweishouwenNeirong.setDangqianhuanjie(xingzhengfawenNeirongBO.dangQianHuanJie(dangweishouwenNeirong.getFlowid()));
				dangweishouwenNeirongList.add(dangweishouwenNeirong);
			}
		}
		*/
		return dangweishouwenNeirongList;
	}

	/**
	 * 党办发文待办
	 * @param request
	 * @return
	 */
	private List<TDangweifawenNeirong> selectTDangWeiFawenDaiBan(Integer useridInt){
		List<TDangweifawenNeirong> dangweifawenNeirongList  = new ArrayList<TDangweifawenNeirong>();
		List<TDangweifawenNeirong> dangweifawenFengFaNeirongList  = new ArrayList<TDangweifawenNeirong>();
//		String path = arg2.getContextPath();
//		String basePath = arg2.getScheme()+"://"+arg2.getServerName()+":"+arg2.getServerPort()+path+"/";
//		List list2 = new ArrayList();
//		JSONArray array = new JSONArray();
//		List list = workFlowTemplate.selectTask(useridInt.toString(), "党委发文");
		List list = xingzhengfawenNeirongBO.selectTaskInstanceByUserIdAndProcessName(useridInt, "党委发文");
//		List list1 = workFlowTemplate.selectTask(SessionUser.getUserId(arg2).toString(), "党委直接发文");
//		for (Iterator iterator = list1.iterator(); iterator.hasNext();) {
//			TaskInstance instance = (TaskInstance) iterator.next();
//			instance.setDescription("首页待办");
//			list.add(instance);
//		}
//		 Comparator comp = new Comparator(){
//	          public int compare(Object o1,Object o2) {
//	              TaskInstance p1=(TaskInstance)o1;
//	              TaskInstance p2=(TaskInstance)o2; 
//	             if(p1.getId()<p2.getId())
//	                 return 1;
//	             else
//	                 return 0;
//	             }
//	        };
//	        Collections.sort(list, comp);
		for (Iterator iterator = list.iterator(); iterator.hasNext();) {
			TaskInstance taskInstance = (TaskInstance) iterator.next();
			Long flowid =	Long.valueOf(taskInstance.getPriority()); 
		//	Long flowid =	taskInstance.getProcessInstance().getId();
			TDangweifawenNeirong dangweifawenNeirong = new TDangweifawenNeirong();
			dangweifawenNeirong.setFlowid(Integer.parseInt(flowid.toString()));
			if(dangweifawenNeirongBO.findByExample(dangweifawenNeirong).size() >0)
			{
				dangweifawenNeirong = (TDangweifawenNeirong)dangweifawenNeirongBO.findByExample(dangweifawenNeirong).get(0);
				dangweifawenNeirong.setTaskId(taskInstance.getId());
				
				if (taskInstance.getDescription().equals("首页待办")) {
					dangweifawenNeirong.setFenshu("首页待办");
				}
				dangweifawenNeirong.setDangqianhuanjie(xingzhengfawenNeirongBO.dangQianHuanJie(dangweifawenNeirong.getFlowid()));
				if ("封发".equals(dangweifawenNeirong.getDangqianhuanjie())) {
					dangweifawenFengFaNeirongList.add(dangweifawenNeirong);
				} else {
					dangweifawenNeirongList.add(dangweifawenNeirong);
				}
				
			}
		}
		dangweifawenNeirongList.addAll(dangweifawenFengFaNeirongList);
		return dangweifawenNeirongList;
	}

	
	/**
	 * 行政收文待办
	 * @param arg2
	 * @return
	 */
	private List<TXingzhengshouwenNeirong> selectTXingzhengShouwenNeirongDaiBan(Integer useridInt){
		
		List<TXingzhengshouwenNeirong> xingzhengshouwenNeirongList = new ArrayList<TXingzhengshouwenNeirong>();
		xingzhengshouwenNeirongList = xingzhengshouwenNeirongBO.selectXingZhengShouWenDaiBan(useridInt);
		return xingzhengshouwenNeirongList;
	}
	
	/**
	 * 行政发文待办
	 * @param arg2
	 * @return
	 */
	private List<TXingzhengfawenNeirong> selectTXingzhengfawenNeirongDaiBan(Integer useridInt){
		List<TXingzhengfawenNeirong> xingzhengfawenNeirongList = new ArrayList<TXingzhengfawenNeirong>(); 
		List<TXingzhengfawenNeirong> xingzhengfawenNeirongFengFaList = new ArrayList<TXingzhengfawenNeirong>(); 
//		String path = arg2.getContextPath();
//		String basePath = arg2.getScheme()+"://"+arg2.getServerName()+":"+arg2.getServerPort()+path+"/";
//		List list2 = new ArrayList();
//		JSONArray array = new JSONArray();
		List list = xingzhengfawenNeirongBO.selectTaskInstanceByUserIdAndProcessName(useridInt,"行政发文");
		for (Iterator iterator = list.iterator(); iterator.hasNext();) {
			TaskInstance taskInstance = (TaskInstance) iterator.next();
			Long flowid =	Long.valueOf(taskInstance.getPriority()); 
			TXingzhengfawenNeirong xingzhengfawenNeirong = new TXingzhengfawenNeirong();
			xingzhengfawenNeirong.setFlowid(Integer.parseInt(flowid.toString()));
			if(xingzhengfawenNeirongBO.findByExample(xingzhengfawenNeirong).size() >0)
			{
				xingzhengfawenNeirong = (TXingzhengfawenNeirong)xingzhengfawenNeirongBO.findByExample(xingzhengfawenNeirong).get(0);
				xingzhengfawenNeirong.setTaskId(taskInstance.getId());
				
				if (taskInstance.getDescription().equals("首页待办")) {
					xingzhengfawenNeirong.setFenshu("首页待办");
				}
				xingzhengfawenNeirong.setDangqianhuanjie(xingzhengfawenNeirongBO.dangQianHuanJie(xingzhengfawenNeirong.getFlowid()));
				if ("封发".equals(xingzhengfawenNeirong.getDangqianhuanjie())) {
					xingzhengfawenNeirongFengFaList.add(xingzhengfawenNeirong);
				} else {
					xingzhengfawenNeirongList.add(xingzhengfawenNeirong);
				}
				
			}
		}
		xingzhengfawenNeirongList.addAll(xingzhengfawenNeirongFengFaList);
		return xingzhengfawenNeirongList;
	}

	/**
	 * 纪委发文待办
	 * @param request
	 * @return
	 */
	private List<TDangweifawenNeirong> selectTJiWeiFawenDaiBan(Integer useridInt){
		List<TDangweifawenNeirong> dangweifawenNeirongList  = new ArrayList<TDangweifawenNeirong>();
//		String path = arg2.getContextPath();
//		String basePath = arg2.getScheme()+"://"+arg2.getServerName()+":"+arg2.getServerPort()+path+"/";
//		List list2 = new ArrayList();
//		JSONArray array = new JSONArray();
	//	List list = workFlowTemplate.selectTask(SessionUser.getUserId(arg2).toString(), "纪委发文");
		List list = xingzhengfawenNeirongBO.selectTaskInstanceByUserIdAndProcessName(useridInt, "纪委发文");

		for (Iterator iterator = list.iterator(); iterator.hasNext();) {
			TaskInstance taskInstance = (TaskInstance) iterator.next();
//			Long flowid =	taskInstance.getProcessInstance().getId();
			Long flowid =	Long.valueOf(taskInstance.getPriority()); 
			TDangweifawenNeirong dangweifawenNeirong = new TDangweifawenNeirong();
			dangweifawenNeirong.setFlowid(Integer.parseInt(flowid.toString()));
			if(dangweifawenNeirongBO.findByExample(dangweifawenNeirong).size() >0)
			{
				dangweifawenNeirong = (TDangweifawenNeirong)dangweifawenNeirongBO.findByExample(dangweifawenNeirong).get(0);
				dangweifawenNeirong.setTaskId(taskInstance.getId());
				
				if (taskInstance.getDescription().equals("首页待办")) {
					dangweifawenNeirong.setFenshu("首页待办");
				}
				dangweifawenNeirong.setDangqianhuanjie(xingzhengfawenNeirongBO.dangQianHuanJie(dangweifawenNeirong.getFlowid()));

				dangweifawenNeirongList.add(dangweifawenNeirong);
			}
		}

		return dangweifawenNeirongList;
		
	}
	
	
	/**
	 * 团委发文待办
	 * @param request
	 * @return
	 */
	private List<TDangweifawenNeirong> selectTTuanWeiFawenDaiBan(Integer useridInt){
		List<TDangweifawenNeirong> dangweifawenNeirongList  = new ArrayList<TDangweifawenNeirong>();
//		String path = arg2.getContextPath();
//		String basePath = arg2.getScheme()+"://"+arg2.getServerName()+":"+arg2.getServerPort()+path+"/";
//		List list2 = new ArrayList();
//		JSONArray array = new JSONArray();
		//List list = workFlowTemplate.selectTask(useridInt, "团委发文");
		List list = xingzhengfawenNeirongBO.selectTaskInstanceByUserIdAndProcessName(useridInt, "团委发文");
		for (Iterator iterator = list.iterator(); iterator.hasNext();) {
			TaskInstance taskInstance = (TaskInstance) iterator.next();
//			Long flowid =	taskInstance.getProcessInstance().getId();
			Long flowid =	Long.valueOf(taskInstance.getPriority()); 
			TDangweifawenNeirong dangweifawenNeirong = new TDangweifawenNeirong();
			dangweifawenNeirong.setFlowid(Integer.parseInt(flowid.toString()));
			if(dangweifawenNeirongBO.findByExample(dangweifawenNeirong).size() >0)
			{
				dangweifawenNeirong = (TDangweifawenNeirong)dangweifawenNeirongBO.findByExample(dangweifawenNeirong).get(0);
				dangweifawenNeirong.setTaskId(taskInstance.getId());
				
				if (taskInstance.getDescription().equals("首页待办")) {
					dangweifawenNeirong.setFenshu("首页待办");
				}
				dangweifawenNeirong.setDangqianhuanjie(xingzhengfawenNeirongBO.dangQianHuanJie(dangweifawenNeirong.getFlowid()));

				dangweifawenNeirongList.add(dangweifawenNeirong);
			}
		}

		return dangweifawenNeirongList;
	}
	
	/**
	 * 工会发文待办
	 * @param request
	 * @return
	 */
	private List<TDangweifawenNeirong> selectTGongHuiFawenDaiBan(Integer useridInt){
		List<TDangweifawenNeirong> dangweifawenNeirongList  = new ArrayList<TDangweifawenNeirong>();
//		String path = arg2.getContextPath();
//		String basePath = arg2.getScheme()+"://"+arg2.getServerName()+":"+arg2.getServerPort()+path+"/";
//		List list2 = new ArrayList();
//		JSONArray array = new JSONArray();
	//	List list = workFlowTemplate.selectTask(useridInt, "工会发文");
		List list = xingzhengfawenNeirongBO.selectTaskInstanceByUserIdAndProcessName(useridInt, "工会发文");
		
		for (Iterator iterator = list.iterator(); iterator.hasNext();) {
			TaskInstance taskInstance = (TaskInstance) iterator.next();
//			Long flowid =	taskInstance.getProcessInstance().getId();
			Long flowid =	Long.valueOf(taskInstance.getPriority()); 
			TDangweifawenNeirong dangweifawenNeirong = new TDangweifawenNeirong();
			dangweifawenNeirong.setFlowid(Integer.parseInt(flowid.toString()));
			if(dangweifawenNeirongBO.findByExample(dangweifawenNeirong).size() >0)
			{
				dangweifawenNeirong = (TDangweifawenNeirong)dangweifawenNeirongBO.findByExample(dangweifawenNeirong).get(0);
				dangweifawenNeirong.setTaskId(taskInstance.getId());
				
				if (taskInstance.getDescription().equals("首页待办")) {
					dangweifawenNeirong.setFenshu("首页待办");
				}
				dangweifawenNeirong.setDangqianhuanjie(xingzhengfawenNeirongBO.dangQianHuanJie(dangweifawenNeirong.getFlowid()));

				dangweifawenNeirongList.add(dangweifawenNeirong);
			}
		}
		return dangweifawenNeirongList;

	}

}
